home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRONOM / H139.ZIP / UI101.ZIP / IO / UI / UI_INIT.C < prev    next >
C/C++ Source or Header  |  1991-11-04  |  4KB  |  128 lines

  1. /****************************************************************
  2.  
  3.     ui_init.c       Initialization routines for
  4.             The Bywater Graphical User Interface
  5.  
  6.             Copyright (c) 1991, Ted A. Campbell
  7.  
  8.             Bywater Software
  9.             P. O. Box 4023 
  10.             Duke Station 
  11.             Durham, NC  27706
  12.  
  13.             email: tcamp@hercules.acpub.duke.edu
  14.  
  15.     Copyright and Permissions Information:
  16.  
  17.     All U.S. and international copyrights are claimed by the
  18.     author. The author grants permission to use this code
  19.     and software based on it under the following conditions:
  20.     (a) in general, the code and software based upon it may be 
  21.     used by individuals and by non-profit organizations; (b) it
  22.     may also be utilized by governmental agencies in any country,
  23.     with the exception of military agencies; (c) the code and/or
  24.     software based upon it may not be sold for a profit without
  25.     an explicit and specific permission from the author, except
  26.     that a minimal fee may be charged for media on which it is
  27.     copied, and for copying and handling; (d) the code must be 
  28.     distributed in the form in which it has been released by the
  29.     author; and (e) the code and software based upon it may not 
  30.     be used for illegal activities. 
  31.  
  32. ****************************************************************/
  33.  
  34. #include "stdio.h"
  35. #include "gr.h"
  36. #include "kb.h"
  37. #include "dr.h"
  38. #include "ui.h"
  39.  
  40. #ifdef __STDC__
  41. #include "stdlib.h"
  42. #else
  43. extern char *getenv();
  44. #endif
  45.  
  46. static struct  gr_window ui_fullscreen;
  47. char ui_tbuf[ 128 ];
  48. int  ui_screen = GR_PRIMARY;
  49. int  x_savescreen;
  50. struct gr_window    *ui_grwind;
  51. char   ui_ready = 0;
  52. char   ui_fontpath[ 128 ];
  53. struct pbm_struct ui_elicon;         /* elevator icon */
  54. struct pbm_struct ui_lefticn;        /* left icon */
  55. struct pbm_struct ui_righticn;       /* right icon */
  56. struct pbm_struct ui_upicn;          /* up icon */
  57. struct pbm_struct ui_downicn;        /* down icon */
  58. struct pbm_struct ui_clicon;         /* close window icon */
  59. struct pbm_struct ui_reicon;         /* resize window icon */
  60. struct pbm_struct ui_mvicon;         /* move window icon */
  61. struct pbm_struct ui_deficon;        /* default file icon */
  62. struct pbm_struct ui_foldicon;       /* file folder icon */
  63. struct pbm_struct ui_exicon;         /* executable file icon */
  64.  
  65. ui_init()
  66.    {
  67.    char *pp;                            /* temp path pointer */
  68.  
  69.    /* See if BWPATH variable is set */
  70.  
  71.    if ( ( pp = getenv( BWENVARNAME ) ) != NULL )
  72.       {
  73.       sprintf( ui_fontpath, "%s%c", pp, dr_fs );
  74.       }
  75.  
  76.    /* Initialize the screen and keyboard */
  77.  
  78.    gr_init( &ui_fullscreen, ui_fontpath );
  79.    kb_init();
  80.  
  81.    gr_font( GR_PRIMARY, F_DEFAULT,
  82.       ui_fullscreen.ymax / DEFAULT_FONT_SIZE );
  83.  
  84.    ui_grwind = &ui_fullscreen;
  85.    ui_setscreen( GR_PRIMARY );
  86.  
  87.    ui_ready = TRUE;
  88.  
  89.    /* initialize icons */
  90.  
  91.    ui_seticons( BLACK, WHITE );
  92.  
  93.    }
  94.  
  95. ui_setscreen( screen )
  96.    int screen;
  97.    {
  98.    ui_screen = screen;
  99.    }
  100.  
  101. ui_push()
  102.    {
  103.    x_savescreen = ui_screen;
  104.    }
  105.  
  106. ui_pop()
  107.    {
  108.    ui_screen = x_savescreen;
  109.    }
  110.  
  111. ui_seticons( foreground, background )
  112.    int foreground, background;
  113.    {
  114.  
  115.    ui_pbmread( "elevator.pbm", &ui_elicon, background, foreground );
  116.    ui_pbmread( "left.pbm", &ui_lefticn, foreground, background );
  117.    ui_pbmread( "right.pbm", &ui_righticn, foreground, background );
  118.    ui_pbmread( "up.pbm", &ui_upicn, foreground, background );
  119.    ui_pbmread( "down.pbm", &ui_downicn, foreground, background );
  120.    ui_pbmread( "close.pbm", &ui_clicon, foreground, background );
  121.    ui_pbmread( "resize.pbm", &ui_reicon, foreground, background );
  122.    ui_pbmread( "move.pbm", &ui_mvicon, foreground, background );
  123.    ui_pbmread( "default.pbm", &ui_deficon, foreground, background );
  124.    ui_pbmread( "folder.pbm", &ui_foldicon, foreground, background );
  125.    ui_pbmread( "exec.pbm", &ui_exicon, foreground, background );
  126.  
  127.    }
  128.